from transformers import BertConfig, BertModel, BertTokenizer, EncoderDecoderModel

model = EncoderDecoderModel.from_encoder_decoder_pretrained('bert-base-chinese', 'bert-base-chinese', config=None)

# 这里也可以传模型的路径而不是模型名字
# model = EncoderDecoderModel.from_encoder_decoder_pretrained('bert-large-uncased','bert-base-chinese',config=None)

decoder_tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')
encoder_tokenizer = BertTokenizer.from_pretrained('bert-base-chinese')
encoder_config = model.config.encoder
decoder_config = model.config.decoder